/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cardgame;

import cardgame.game.Mana;
import cardgame.game.ManaAmount;
import java.awt.Graphics;
import java.awt.Image;

/**
 *
 * @author Carl
 */
public class PanCardInfo_Mana extends javax.swing.JPanel{

    public PanCardInfo_Mana(int size){
        initComponents();
        this.size = size;
    }
    private ManaAmount manaAmount;
    private int padding = 0;
    private int size;

    @Override
    protected void paintComponent(Graphics graphics){
        super.paintComponent(graphics);
        if(manaAmount != null){
            int x = 0;
            int y = 0;
            for(int i=0;i<Mana.values().length;i++){
                int amount = manaAmount.getMana(Mana.values()[i]);
                Image image = PanCard.getCachedImage("/cardgame/resources/images/mana/" + i + ".png");
                for(int r=0;r<amount;r++){
                    graphics.drawImage(image, x, y, size, size, this);
                    x += (size + padding);
                    if((x + size + padding) > getWidth()){
                        x = 0;
                        y += (size + padding);
                    }
                }
            }
        }
    }

    public void setManaAmount(ManaAmount manaAmount){
        this.manaAmount = manaAmount;
        updateUI();
    }

    public ManaAmount getManaAmount(){
        return manaAmount;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setOpaque(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
